package com.boot.message.netty.server;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 * @author 霜寒 <1621856595@qq.com>
 * @description netty服务端配置
 * @date 2019/11/21 13:22
 **/
@Component
@ConfigurationProperties(prefix = "netty.server")
@Data
public class NettyServerProperties {
    /**
     * @description 开启选项
     * @date 2019/12/16 21:30
     **/
    private boolean enable = false;
    /**
     * @description 服务器端口
     * @date 2019/12/16 19:36
     **/
    @NotNull
    @Size(min = 1000, max = 65535)
    private int port = 0;
    /**
     * @description 监听线程组数量
     * @date 2019/12/16 19:37
     **/
    @NotNull
    @Min(1)
    private int bossCount = 4;
    /**
     * @description 处理请求线程组数量
     * @date 2019/12/16 19:38
     **/
    @NotNull
    @Min(1)
    private int workerCount = 8;
    /**
     * @description 保持TCP长连接
     * @date 2019/12/16 19:38
     **/
    @NotNull
    private boolean keepAlive = true;
    /**
     * @description 服务端可连接队列数, 对应TCP/IP协议listen函数中backlog参数
     * @date 2019/12/16 19:36
     **/
    @NotNull
    private int backlog = 1024;
    /**
     * @description 缓存区大小
     * @date 2019/12/16 19:40
     **/
    @NotNull
    private int buffer = 16 * 1024;
}
